home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Analysis
/
Peak Fitting
/
Peak Functions
< prev
Wrap
Text File
|
1994-11-14
|
5KB
|
273 lines
|
| The functions in this file are user defined versions of the XFUNCs provided by the
| GaussFit, LorentzianFit and VoigtFit XOP modules. They are provided mainly
| for use when you are running on a 68K machine that lacks a floating point
| processor unit (i.e., a 68LC040 machine such as a notebook). They can also be
| uesd to get an idea how much faster XFUNCs are than user defined functions.
|
| The names of the functions provided here are the same as the corresponding
| XFUNCs except these have a prefix of "f".
|
| For documentation, see the coresponding documentation for the above named
| XFUNCs.
|************* Gaussian *************
Function fGaussFit(w,x)
Wave w; Variable x
Variable r= w[0]
variable npts= numpnts(w),i=1
do
if( i>=npts )
break
endif
r += w[i]*exp(-((x-w[i+1])/w[i+2])^2)
i+=3
while(1)
return r
End
Function fGaussFitBL(w,x)
Wave w; Variable x
Variable xprime= (x-w[0])/w[1]
Variable r= w[2]+w[3]*xprime+w[4]*xprime^2+w[5]*xprime^3
variable npts= numpnts(w),i=6
do
if( i>=npts )
break
endif
r += w[i]*exp(-((x-w[i+1])/w[i+2])^2)
i+=3
while(1)
return r
End
Function fGaussFit1Width(w,x)
Wave w; Variable x
Variable r= w[0],width= w[1]
variable npts= numpnts(w),i=2
do
if( i>=npts )
break
endif
r += w[i]*exp(-((x-w[i+1])/width)^2)
i+=2
while(1)
return r
End
Function fGaussFit1WidthBL(w,x)
Wave w; Variable x
Variable xprime= (x-w[0])/w[1],width= w[6]
Variable r= w[2]+w[3]*xprime+w[4]*xprime^2+w[5]*xprime^3
variable npts= numpnts(w),i=7
do
if( i>=npts )
break
endif
r += w[i]*exp(-((x-w[i+1])/width)^2)
i+=2
while(1)
return r
End
|************* Lorentzian *************
Function fLorentzianFit(w,x)
Wave w; Variable x
Variable r= w[0]
variable npts= numpnts(w),i=1
do
if( i>=npts )
break
endif
r += w[i]/((x-w[i+1])^2+w[i+2])
i+=3
while(1)
return r
End
Function fLorentzianFitBL(w,x)
Wave w; Variable x
Variable xprime= (x-w[0])/w[1]
Variable r= w[2]+w[3]*xprime+w[4]*xprime^2+w[5]*xprime^3
variable npts= numpnts(w),i=6
do
if( i>=npts )
break
endif
r += w[i]/((x-w[i+1])^2+w[i+2])
i+=3
while(1)
return r
End
Function fLorentzianFit1Width(w,x)
Wave w; Variable x
Variable r= w[0],width= w[1]
variable npts= numpnts(w),i=2
do
if( i>=npts )
break
endif
r += w[i]/((x-w[i+1])^2+width)
i+=2
while(1)
return r
End
Function fLorentzianFit1WidthBL(w,x)
Wave w; Variable x
Variable xprime= (x-w[0])/w[1],width= w[6]
Variable r= w[2]+w[3]*xprime+w[4]*xprime^2+w[5]*xprime^3
variable npts= numpnts(w),i=7
do
if( i>=npts )
break
endif
r += w[i]/((x-w[i+1])^2+width)
i+=2
while(1)
return r
End
|************* Voigt *************
Function fVoigt(X,Y)
variable X,Y
Y= abs(Y)
X= abs(X)
variable/C W,U,T= cmplx(Y,-X)
variable S= X+Y
if( S >= 15 ) | Region I
W= T*0.5641896/(0.5+T*T)
else
if( S >= 5.5 ) | Region II
U= T*T
W= T*(1.410474+U*0.5641896)/(0.75+U*(3+U))
else
if( Y >= (0.195*X-0.176) ) | Region III
W= (16.4955+T*(20.20933+T*(11.96482+T*(3.778987+T*0.5642236))))
W /= (16.4955+T*(38.82363+T*(39.27121+T*(21.69274+T*(6.699398+T)))))
else | Region IV
U= T*T
W= T*(36183.31-U*(3321.9905-U*(1540.787-U*(219.0313-U*(35.76683-U*(1.320522-U*0.56419))))))
W /= (32066.6-U*(24322.84-U*(9022.228-U*(2186.181-U*(364.2191-U*(61.57037-U*(1.841439-U)))))))
W= cmplx(exp(real(U))*cos(imag(U)),0)-W
endif
endif
endif
return real(W)
end
Function fVoigtFit(w,x)
Wave w; Variable x
Variable r= w[0]
variable npts= numpnts(w),i=1
do
if( i>=npts )
break
endif
r += w[i]*fVoigt(w[i+1]*(x-w[i+2]),w[i+3])
i+=4
while(1)
return r
End
Function fVoigtFitBL(w,x)
Wave w; Variable x
Variable xprime= (x-w[0])/w[1]
Variable r= w[2]+w[3]*xprime+w[4]*xprime^2+w[5]*xprime^3
variable npts= numpnts(w),i=6
do
if( i>=npts )
break
endif
r += w[i]*fVoigt(w[i+1]*(x-w[i+2]),w[i+3])
i+=4
while(1)
return r
End
Function fVoigtFit1Shape(w,x)
Wave w; Variable x
Variable r= w[0],shape= w[1]
variable npts= numpnts(w),i=2
do
if( i>=npts )
break
endif
r += w[i]*fVoigt(w[i+1]*(x-w[i+2]),shape)
i+=3
while(1)
return r
End
Function fVoigtFit1ShapeBL(w,x)
Wave w; Variable x
Variable xprime= (x-w[0])/w[1],shape= w[6]
Variable r= w[2]+w[3]*xprime+w[4]*xprime^2+w[5]*xprime^3
variable npts= numpnts(w),i=7
do
if( i>=npts )
break
endif
r += w[i]*fVoigt(w[i+1]*(x-w[i+2]),shape)
i+=3
while(1)
return r
End
Function fVoigtFit1Shape1Width(w,x)
Wave w; Variable x
Variable r= w[0],shape= w[1],width= w[2]
variable npts= numpnts(w),i=3
do
if( i>=npts )
break
endif
r += w[i]*fVoigt(width*(x-w[i+1]),shape)
i+=2
while(1)
return r
End
Function fVoigtFit1Shape1WidthBL(w,x)
Wave w; Variable x
Variable xprime= (x-w[0])/w[1],shape= w[6],width= w[7]
Variable r= w[2]+w[3]*xprime+w[4]*xprime^2+w[5]*xprime^3
variable npts= numpnts(w),i=8
do
if( i>=npts )
break
endif
r += w[i]*fVoigt(width*(x-w[i+1]),shape)
i+=2
while(1)
return r
End